[slug].vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <script lang='ts' setup>
  2. import { useCommonStore } from '@/stores/modules/common'
  3. import { ConstKeys } from '~/enums/const-enums'
  4. import { Api } from '@/api/model/url'
  5. const route = useRoute()
  6. const commonStore = useCommonStore()
  7. const list = ref<any>([])
  8. const slug = route.params.slug
  9. const { data: res } = await useAsyncData(
  10. 'category-detail',
  11. () =>
  12. $fetch(`${ConstKeys.DOMAINDEV}${Api.CategoryDetail}`, { params: { slug } }),
  13. )
  14. const seoData = res.value?.result
  15. const { data: res2 } = await useAsyncData(
  16. 'category-catalogue-list',
  17. () =>
  18. $fetch(`${ConstKeys.DOMAINDEV}${Api.CategoryCatalogueList}`, { params: { slug } }),
  19. )
  20. list.value = res2.value?.result?.records || []
  21. const { openLoginAndDownloadModal } = useLoginAndDownLoadModal()
  22. async function clickLoginAndDownload(item: any) {
  23. try {
  24. commonStore.setDownloadCatalog(item)
  25. const { status } = await openLoginAndDownloadModal()
  26. if (status)
  27. location.reload()
  28. }
  29. catch (error) {
  30. console.log(error)
  31. }
  32. }
  33. const firstTitle = computed(() => {
  34. return seoData?.contentTitle ? handleTitle(seoData.contentTitle, 1) : ''
  35. })
  36. const secondTitle = computed(() => {
  37. return seoData?.contentTitle ? handleTitle(seoData.contentTitle, 2) : ''
  38. })
  39. function handleTitle(title: string | undefined, position: number) {
  40. if (!title)
  41. return ''
  42. // 先判断标题中是否带有&,获取第一个&之前的数据和之后的数据
  43. let firstPart = ''
  44. let secondPart = ''
  45. const index = title.indexOf('&')
  46. if (index !== -1) {
  47. firstPart = title.slice(0, index).trim()
  48. secondPart = title.slice(index + 1).trim()
  49. }
  50. else {
  51. // 如果没有&,返回第一个空格之前的数据和之后的数据
  52. const spaceIndex = title.indexOf(' ')
  53. if (spaceIndex !== -1) {
  54. firstPart = title.slice(0, spaceIndex).trim()
  55. secondPart = title.slice(spaceIndex + 1).trim()
  56. }
  57. }
  58. return position === 1 ? firstPart : secondPart || ''
  59. }
  60. </script>
  61. <template>
  62. <div>
  63. <div class=" bg-#0F0820 header">
  64. <div class=" w-1200-auto pos-relative text-center flex items-center justify-start h-600px bg-no-repeat bg-center">
  65. <h1 class="text-58px fw-800 text-#fff ls-2 custom-title-font">
  66. <span class="flex items-center">
  67. {{ firstTitle }}<svgo-flower class="w-44px h-44px !text-#FFFF66 ml-20px" />
  68. </span>
  69. <span class="flex items-center">
  70. <svgo-star-blue class="w-44px h-44px text-#1AC18E mr-20px" /> {{ secondTitle }}
  71. </span>
  72. </h1>
  73. <div class="pos-absolute right-0 bottom-76px w-426px h-340px header-img-bg flex justify-center items-center">
  74. <img :src="seoData.bannerImg" alt="" class="w-full h-390px object-contain mb-40px">
  75. </div>
  76. </div>
  77. </div>
  78. <div class="py-120px w-1200-auto text-center">
  79. <h2 class="text-36px fw-800 text-#333 !mb-20px custom-title-font">
  80. Our Latest Product <span class="custom-title-bg04">Catalogs</span>
  81. </h2>
  82. <div class="text-#999 text-22px mb-40px">
  83. Discover bestsellers and fresh arrivals tailored to your niche.
  84. </div>
  85. <div class="grid grid-cols-2 gap-64px text-left">
  86. <div v-for="item in list" :key="item.id">
  87. <business-categories-comp-item :item="item" @select="clickLoginAndDownload" />
  88. </div>
  89. </div>
  90. </div>
  91. <common-block-catalogs />
  92. <common-block-blog class="!pb-0" />
  93. <AppFooter />
  94. </div>
  95. </template>
  96. <style lang='less' scoped>
  97. .header{
  98. background-image: url('@/assets/images/catalogue_bg.png');
  99. background-position: center center;
  100. background-size: cover;
  101. .header-img-bg{
  102. background-image: url('@/assets/images/catalogue_bg_img.png');
  103. background-size: cover;
  104. background-position: center;
  105. }
  106. }
  107. </style>